#include <stdio.h>
#include <string.h>

#define STDIN
//#define DEBUG

#define MAX_WORDS 1000
char words[MAX_WORDS][21];
int n;
short len_prfix[MAX_WORDS];

void compute_prefix(int wordi, int wordj)
{
    int wi = 0;
    while (1)
    {
        if (words[wordi][wi] == '\0')
        {
            len_prfix[wordi] = wi;
            if (len_prfix[wordj] < wi+1)
                len_prfix[wordj] = wi+1;
            break;
        }

        if (words[wordj][wi] == '\0')
        {
            len_prfix[wordj] = wi;
            if (len_prfix[wordi] < wi+1)
                len_prfix[wordi] = wi+1;
            break;
        }
        if (words[wordi][wi] == words[wordj][wi])
            wi++;
        else
        {
            if (len_prfix[wordi] < wi+1)
                len_prfix[wordi] = wi+1;
            if (len_prfix[wordj] < wi+1)
                len_prfix[wordj] = wi+1;
            break;
        }
    }
#ifdef DEBUG
    printf("wrodi: %d wordj: %d\n", wordi, wordj);
    printf("%s:%d %s:%d wi: %d\n", words[wordi], len_prfix[wordi], words[wordj], len_prfix[wordj], wi);
#endif
}

void process()
{
    int wordi, wordj;
    len_prfix[0] = 1;
#ifdef DEBUG
    printf("n: %d\n", n);
#endif

    for (wordi = 1; wordi < n; ++wordi)
    {
        for (wordj = 0; wordj < wordi; wordj++)
        {
        compute_prefix(wordj, wordi);
        }
    }
#ifdef DEBUG
    for (wordi = 0; wordi < n; ++wordi)
    {
        printf("%s: %d\n", words[wordi], len_prfix[wordi]);
    }
#endif
    for (wordi = 0; wordi < n; ++wordi)
    {
        printf("%s ", words[wordi]);
        words[wordi][len_prfix[wordi]] = '\0';
        printf("%s\n",words[wordi]);
    }

}

int main()
{
#ifdef STDIN
    freopen("bin/2001.in", "r", stdin);
#endif

    n = 0;
    int ret;
    while(1)
    {
        ret = scanf("%s", words[n]);
        if (ret == EOF)
            break;
        if ((words[n][0] == ' ') || strlen(words[n]) == 0)
                break;
        n++;
    }
#ifdef DEBUG
    int i;
    for (i = 0; i < n; ++i)
    {
        printf("i: %d %s\n", i, words[i]);
    }
#endif
    process();

    return 0;
}
